﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Util;
using BLL;
using iTextSharp.text.pdf;

public partial class relatorio : Pagina
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Report r = new Report();

        SendOutPDF(r.CriarRelatorio(Busca.SelecionarTodos()));
    }

    protected void SendOutPDF(System.IO.MemoryStream PDFData)
    {
        // Clear response content & headers
        Response.Clear();
        Response.ClearContent();
        Response.ClearHeaders();
        Response.ContentType = "application/pdf";
        Response.Charset = string.Empty;
        Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
        Response.AddHeader("Content-Disposition",
            "attachment; filename=relatorio.pdf");

        Response.OutputStream.Write(PDFData.GetBuffer(), 0, PDFData.GetBuffer().Length);
        Response.OutputStream.Flush();
        Response.OutputStream.Close();
        Response.End();
    }

}